home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / bladestl.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  20KB  |  559 lines

  1. /***************************************************************************
  2.  
  3. Blades of Steel(GX797) (c) 1987 Konami
  4.  
  5. Driver by Manuel Abadia <manu@teleline.es>
  6.  
  7. Interrupts:
  8.  
  9.     CPU #0 (6309):
  10.     --------------
  11.     * IRQ: not used.
  12.     * FIRQ: generated by VBLANK.
  13.     * NMI: writes the sound command to the 6809.
  14.  
  15.     CPU #1 (6809):
  16.     --------------
  17.     * IRQ: triggered by the 6309 when a sound command is written.
  18.     * FIRQ: not used.
  19.     * NMI: not used.
  20.  
  21. Notes:
  22.     * The protection is not fully understood(Konami 051733). The
  23.     game is playable, but is not 100% accurate.
  24.     * Missing samples.
  25.  
  26. ***************************************************************************/
  27.  
  28. #include "driver.h"
  29. #include "cpu/m6809/m6809.h"
  30. #include "vidhrdw/generic.h"
  31. #include "vidhrdw/konamiic.h"
  32.  
  33. /* from vidhrdw */
  34. int bladestl_spritebank;
  35. int bladestl_vh_start(void);
  36. void bladestl_vh_stop(void);
  37. void bladestl_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  38. void bladestl_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  39. WRITE_HANDLER( bladestl_vreg_w );
  40.  
  41. static int bladestl_interrupt( void )
  42. {
  43.     if (cpu_getiloops() == 0){
  44.         if (K007342_is_INT_enabled())
  45.             return HD6309_INT_FIRQ;
  46.     }
  47.     else if (cpu_getiloops() % 2){
  48.         return nmi_interrupt();
  49.     }
  50.     return ignore_interrupt();
  51. }
  52.  
  53. static READ_HANDLER( trackball_r )
  54. {
  55.     static int last[4];
  56.     int curr,delta;
  57.  
  58.  
  59.     curr = readinputport(5 + offset);
  60.     delta = (curr - last[offset]) & 0xff;
  61.     last[offset] = curr;
  62.     return (delta & 0x80) | (curr >> 1);
  63. }
  64.  
  65. static WRITE_HANDLER( bladestl_bankswitch_w )
  66. {
  67.     unsigned char *RAM = memory_region(REGION_CPU1);
  68.     int bankaddress;
  69.  
  70.     /* bits 0 & 1 = coin counters */
  71.     coin_counter_w(0,data & 0x01);
  72.     coin_counter_w(1,data & 0x02);
  73.  
  74.     /* bits 2 & 3 = lamps */
  75.     osd_led_w(0,(data & 0x04) >> 2);
  76.     osd_led_w(1,(data & 0x08) >> 3);
  77.  
  78.     /* bit 4 = relay (???) */
  79.  
  80.     /* bits 5-6 = bank number */
  81.     bankaddress = 0x10000 + ((data & 0x60) >> 5) * 0x2000;
  82.     cpu_setbank(1,&RAM[bankaddress]);
  83.  
  84.     /* bit 7 = select sprite bank */
  85.     bladestl_spritebank = (data & 0x80) << 3;
  86.  
  87. }
  88.  
  89. static WRITE_HANDLER( bladestl_sh_irqtrigger_w )
  90. {
  91.     soundlatch_w(offset, data);
  92.     cpu_cause_interrupt(1,M6809_INT_IRQ);
  93.     //logerror("(sound) write %02x\n", data);
  94. }
  95.  
  96. static WRITE_HANDLER( bladestl_port_A_w ){
  97.     /* bits 0-4 = uPD7759 sample number (chip 0) */
  98.     //UPD7759_message_w( 0, data);
  99.     //if (data)
  100.     //    logerror("%04x: (port A) write %02x\n",cpu_get_pc(), data);
  101. }
  102.  
  103. static WRITE_HANDLER( bladestl_port_B_w ){
  104.     /* unknown */
  105.     //if (data)
  106.     //    logerror("%04x: (port B) write %02x\n",cpu_get_pc(), data);
  107. }
  108.  
  109. static WRITE_HANDLER( bladestl_speech_ctrl_w ){
  110.     /* not understood yet */
  111.     //if (data)
  112.     //    logerror("%04x: (speech_ctrl) write %02x\n",cpu_get_pc(), data);
  113. }
  114.  
  115. static struct MemoryReadAddress bladestl_readmem[] =
  116. {
  117.     { 0x0000, 0x1fff, K007342_r },            /* Color RAM + Video RAM */
  118.     { 0x2000, 0x21ff, K007420_r },            /* Sprite RAM */
  119.     { 0x2200, 0x23ff, K007342_scroll_r },    /* Scroll RAM */
  120.     { 0x2400, 0x245f, paletteram_r },        /* Palette */
  121.     { 0x2e01, 0x2e01, input_port_3_r },        /* 1P controls */
  122.     { 0x2e02, 0x2e02, input_port_4_r },        /* 2P controls */
  123.     { 0x2e03, 0x2e03, input_port_1_r },        /* DISPW #2 */
  124.     { 0x2e40, 0x2e40, input_port_0_r },        /* DIPSW #1 */
  125.     { 0x2e00, 0x2e00, input_port_2_r },        /* DIPSW #3, coinsw, startsw */
  126.     { 0x2f00, 0x2f03, trackball_r },        /* Trackballs */
  127.     { 0x2f80, 0x2f9f, K051733_r },            /* Protection: 051733 */
  128.     { 0x4000, 0x5fff, MRA_RAM },            /* Work RAM */
  129.     { 0x6000, 0x7fff, MRA_BANK1 },            /* banked ROM */
  130.     { 0x8000, 0xffff, MRA_ROM },            /* ROM */
  131.     { -1 }    /* end of table */
  132. };
  133.  
  134. static struct MemoryWriteAddress bladestl_writemem[] =
  135. {
  136.     { 0x0000, 0x1fff, K007342_w },                /* Color RAM + Video RAM */
  137.     { 0x2000, 0x21ff, K007420_w },                /* Sprite RAM */
  138.     { 0x2200, 0x23ff, K007342_scroll_w },        /* Scroll RAM */
  139.     { 0x2400, 0x245f, paletteram_xBBBBBGGGGGRRRRR_swap_w, &paletteram },/* palette */
  140.     { 0x2600, 0x2607, K007342_vreg_w },            /* Video Registers */
  141.     { 0x2e80, 0x2e80, bladestl_sh_irqtrigger_w },/* cause interrupt on audio CPU */
  142.     { 0x2ec0, 0x2ec0, watchdog_reset_w },        /* watchdog reset */
  143.     { 0x2f40, 0x2f40, bladestl_bankswitch_w },    /* bankswitch control */
  144.     { 0x2f80, 0x2f9f, K051733_w },                /* Protection: 051733 */
  145.     { 0x2fc0, 0x2fc0, MWA_NOP },                /* ??? */
  146.     { 0x4000, 0x5fff, MWA_RAM },                /* Work RAM */
  147.     { 0x6000, 0x7fff, MWA_RAM },                /* banked ROM */
  148.     { 0x8000, 0xffff, MWA_ROM },                /* ROM */
  149.     { -1 }    /* end of table */
  150. };
  151.  
  152. static struct MemoryReadAddress bladestl_readmem_sound[] =
  153. {
  154.     { 0x0000, 0x07ff, MRA_RAM },                /* RAM */
  155.     { 0x1000, 0x1000, YM2203_status_port_0_r },    /* YM2203 */
  156.     { 0x1001, 0x1001, YM2203_read_port_0_r },    /* YM2203 */
  157.     { 0x4000, 0x4000, UPD7759_0_busy_r },        /* UPD7759? */
  158.     { 0x6000, 0x6000, soundlatch_r },            /* soundlatch_r */
  159.     { 0x8000, 0xffff, MRA_ROM },                /* ROM */
  160.     { -1 }    /* end of table */
  161. };
  162.  
  163. static struct MemoryWriteAddress bladestl_writemem_sound[] =
  164. {
  165.     { 0x0000, 0x07ff, MWA_RAM },                /* RAM */
  166.     { 0x1000, 0x1000, YM2203_control_port_0_w },/* YM2203 */
  167.     { 0x1001, 0x1001, YM2203_write_port_0_w },    /* YM2203 */
  168.     { 0x3000, 0x3000, bladestl_speech_ctrl_w },    /* UPD7759 */
  169.     { 0x5000, 0x5000, MWA_NOP },                /* ??? */
  170.     { 0x8000, 0xffff, MWA_ROM },                /* ROM */
  171.     { -1 }    /* end of table */
  172. };
  173.  
  174. /***************************************************************************
  175.  
  176.     Input Ports
  177.  
  178. ***************************************************************************/
  179.  
  180. INPUT_PORTS_START( bladestl )
  181.     PORT_START    /* DSW #1 */
  182.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
  183.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  184.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  185.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  186.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  187.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  188.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  189.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_5C ) )
  190.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  191.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  192.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  193.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  194.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  195.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  196.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  197.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  198.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  199.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  200.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  201.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  202.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  203.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  204.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  205.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  206.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_5C ) )
  207.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  208.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  209.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  210.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  211.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  212.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  213.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  214.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  215.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  216.  
  217.     PORT_START    /* DSW #2 */
  218.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
  219.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  220.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  221.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  222.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  223.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  224.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
  225.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  226.     PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
  227.     PORT_DIPNAME( 0x18, 0x18, "Bonus time set" )
  228.     PORT_DIPSETTING(    0x18, "30 secs" )
  229.     PORT_DIPSETTING(    0x10, "20 secs" )
  230.     PORT_DIPSETTING(    0x08, "15 secs" )
  231.     PORT_DIPSETTING(    0x00, "10 secs" )
  232.     PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )
  233.     PORT_DIPSETTING(    0x60, "Easy" )
  234.     PORT_DIPSETTING(    0x40, "Normal" )
  235.     PORT_DIPSETTING(    0x20, "Difficult" )
  236.     PORT_DIPSETTING(    0x00, "Very difficult" )
  237.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  238.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  239.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  240.  
  241.     PORT_START    /* COINSW */
  242.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  243.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  244.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  245.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
  246.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
  247.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
  248.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  249.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  250.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
  251.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  252.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  253.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  254.  
  255.     PORT_START    /* PLAYER 1 INPUTS */
  256.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  257.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  258.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  259.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  260.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  261.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  262.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  263.     PORT_DIPNAME( 0x80, 0x80, "Period time set" )
  264.     PORT_DIPSETTING(    0x80, "4" )
  265.     PORT_DIPSETTING(    0x00, "7" )
  266.  
  267.  
  268.     PORT_START    /* PLAYER 2 INPUTS */
  269.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  270.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  271.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  272.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  273.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  274.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  275.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  276.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
  277.  
  278.     /* Trackball 1P */
  279.     PORT_START
  280.     PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER1, 100, 63, 0, 0)
  281.     PORT_START
  282.     PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_X | IPF_PLAYER1, 100, 63, 0, 0)
  283.  
  284.     /* Trackball 2P */
  285.     PORT_START
  286.     PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER2, 100, 63, 0, 0)
  287.     PORT_START
  288.     PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_X | IPF_PLAYER2, 100, 63, 0, 0)
  289. INPUT_PORTS_END
  290.  
  291. INPUT_PORTS_START( bladstle )
  292.     PORT_START    /* DSW #1 */
  293.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
  294.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  295.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  296.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  297.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  298.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  299.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  300.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_5C ) )
  301.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  302.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  303.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  304.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  305.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  306.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  307.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  308.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  309.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  310.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  311.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  312.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  313.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  314.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  315.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  316.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  317.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_5C ) )
  318.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  319.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  320.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  321.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  322.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  323.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  324.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  325.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  326.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  327.  
  328.     PORT_START    /* DSW #2 */
  329.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
  330.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  331.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  332.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  333.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  334.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  335.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
  336.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  337.     PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
  338.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  339.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  340.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  341.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  342.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  343.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  344.     PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )
  345.     PORT_DIPSETTING(    0x60, "Easy" )
  346.     PORT_DIPSETTING(    0x40, "Normal" )
  347.     PORT_DIPSETTING(    0x20, "Difficult" )
  348.     PORT_DIPSETTING(    0x00, "Very difficult" )
  349.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  350.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  351.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  352.  
  353.     PORT_START    /* COINSW */
  354.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  355.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  356.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  357.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
  358.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
  359.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
  360.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  361.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  362.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
  363.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  364.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  365.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  366.  
  367.     PORT_START    /* PLAYER 1 INPUTS */
  368.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  369.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  370.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  371.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  372.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  373.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  374.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  375.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  376.  
  377.     PORT_START    /* PLAYER 2 INPUTS */
  378.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  379.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  380.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  381.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  382.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  383.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  384.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  385.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  386.  
  387.     /* Trackball 1P */
  388.     PORT_START
  389.     PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER1, 100, 63, 0, 0)
  390.     PORT_START
  391.     PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_X | IPF_PLAYER1, 100, 63, 0, 0)
  392.  
  393.     /* Trackball 2P */
  394.     PORT_START
  395.     PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER2, 100, 63, 0, 0)
  396.     PORT_START
  397.     PORT_ANALOG( 0xff, 0x00, IPT_TRACKBALL_X | IPF_PLAYER2, 100, 63, 0, 0)
  398. INPUT_PORTS_END
  399.  
  400.  
  401.  
  402. static struct GfxLayout charlayout =
  403. {
  404.     8,8,            /* 8 x 8 characters */
  405.     0x40000/32,        /* 8192 characters */
  406.     4,                /* 4bpp */
  407.     { 0, 1, 2, 3 },    /* the four bitplanes are packed in one nibble */
  408.     { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4 },
  409.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  410.     32*8            /* every character takes 32 consecutive bytes */
  411. };
  412.  
  413. static struct GfxLayout spritelayout =
  414. {
  415.     8,8,            /* 8*8 sprites */
  416.     0x40000/32,        /* 8192 sprites */
  417.     4,                /* 4 bpp */
  418.     { 0, 1, 2, 3 },    /* the four bitplanes are packed in one nibble */
  419.     { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4 },
  420.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  421.     32*8            /* every sprite takes 32 consecutive bytes */
  422. };
  423.  
  424. static struct GfxDecodeInfo gfxdecodeinfo[] =
  425. {
  426.     { REGION_GFX1, 0x000000, &charlayout,     0,    2 },    /* colors 00..31 */
  427.     { REGION_GFX1, 0x040000, &spritelayout,   32,    16 },    /* colors 32..47 but using lookup table */
  428.     { -1 } /* end of array */
  429. };
  430.  
  431. /***************************************************************************
  432.  
  433.     Machine Driver
  434.  
  435. ***************************************************************************/
  436.  
  437. static struct YM2203interface ym2203_interface =
  438. {
  439.     1,                        /* 1 chip */
  440.     3579545,                /* 3.579545 MHz? */
  441.     { YM2203_VOL(45,45) },
  442.     { 0 },
  443.     { 0 },
  444.     { bladestl_port_A_w },    /* uPD7759 (chip 0) */
  445.     { bladestl_port_B_w }    /* uPD7759 (chip 1)??? */
  446. };
  447.  
  448. static struct UPD7759_interface upd7759_interface =
  449. {
  450.     2,                            /* number of chips */
  451.     UPD7759_STANDARD_CLOCK,
  452.     { 60, 50 },                    /* volume */
  453.     { REGION_SOUND1, REGION_SOUND2 },                    /* memory regions */
  454.     UPD7759_STANDALONE_MODE,
  455.     { 0 }
  456. };
  457.  
  458. static struct MachineDriver machine_driver_bladestl =
  459. {
  460.     /* basic machine hardware */
  461.     {
  462.         {
  463.             CPU_HD6309,
  464.             3000000,        /* 24MHz/8 (?) */
  465.             bladestl_readmem,bladestl_writemem,0,0,
  466.             bladestl_interrupt,2 /* (1 IRQ + 1 NMI) */
  467.         },
  468.         {
  469.             CPU_M6809 | CPU_AUDIO_CPU,
  470.             2000000,        /* ? */
  471.             bladestl_readmem_sound, bladestl_writemem_sound,0,0,
  472.             ignore_interrupt,0    /* interrupts are triggered by the main CPU */
  473.         }
  474.     },
  475.     60, DEFAULT_60HZ_VBLANK_DURATION,
  476.     10,
  477.     0,
  478.  
  479.     /* video hardware */
  480.     32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
  481.     gfxdecodeinfo,
  482.     48, 48 + 16*16,
  483.     bladestl_vh_convert_color_prom,
  484.  
  485.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  486.     0,
  487.     bladestl_vh_start,
  488.     bladestl_vh_stop,
  489.     bladestl_vh_screenrefresh,
  490.  
  491.     /* sound hardware */
  492.     0,0,0,0,
  493.     {
  494.         {
  495.             SOUND_YM2203,
  496.             &ym2203_interface
  497.         },
  498.         {
  499.             SOUND_UPD7759,
  500.             &upd7759_interface
  501.         }
  502.     }
  503. };
  504.  
  505. /***************************************************************************
  506.  
  507.   Game ROMs
  508.  
  509. ***************************************************************************/
  510.  
  511. ROM_START( bladestl )
  512.     ROM_REGION( 0x18000, REGION_CPU1 ) /* code + banked roms */
  513.     ROM_LOAD( "797t01.bin", 0x10000, 0x08000, 0x89d7185d )    /* fixed ROM */
  514.     ROM_CONTINUE(            0x08000, 0x08000 )                /* banked ROM */
  515.  
  516.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the sound CPU */
  517.     ROM_LOAD( "797c02", 0x08000, 0x08000, 0x65a331ea )
  518.  
  519.     ROM_REGION( 0x080000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  520.     ROM_LOAD( "797a05",    0x000000, 0x40000, 0x5491ba28 )    /* tiles */
  521.     ROM_LOAD( "797a06",    0x040000, 0x40000, 0xd055f5cc )    /* sprites */
  522.  
  523.     ROM_REGION( 0x0100, REGION_PROMS )
  524.     ROM_LOAD( "797a07", 0x0000, 0x0100, 0x7aecad4e ) /* sprites lookup table */
  525.  
  526.     ROM_REGION( 0x80000, REGION_SOUND1 ) /* uPD7759 data (chip 1) */
  527.     ROM_LOAD( "797a03", 0x00000, 0x80000, 0x9ee1a542 )
  528.  
  529.     ROM_REGION( 0x40000, REGION_SOUND2 ) /* uPD7759 data (chip 2) */
  530.     ROM_LOAD( "797a04",    0x000000, 0x40000, 0x9ac8ea4e )
  531. ROM_END
  532.  
  533. ROM_START( bladstle )
  534.     ROM_REGION( 0x18000, REGION_CPU1 ) /* code + banked roms */
  535.     ROM_LOAD( "797e01", 0x10000, 0x08000, 0xf8472e95 )    /* fixed ROM */
  536.     ROM_CONTINUE(        0x08000, 0x08000 )                /* banked ROM */
  537.  
  538.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the sound CPU */
  539.     ROM_LOAD( "797c02", 0x08000, 0x08000, 0x65a331ea )
  540.  
  541.     ROM_REGION( 0x080000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  542.     ROM_LOAD( "797a05",    0x000000, 0x40000, 0x5491ba28 )    /* tiles */
  543.     ROM_LOAD( "797a06",    0x040000, 0x40000, 0xd055f5cc )    /* sprites */
  544.  
  545.     ROM_REGION( 0x0100, REGION_PROMS )
  546.     ROM_LOAD( "797a07", 0x0000, 0x0100, 0x7aecad4e ) /* sprites lookup table */
  547.  
  548.     ROM_REGION( 0x80000, REGION_SOUND1 ) /* uPD7759 data (chip 1) */
  549.     ROM_LOAD( "797a03", 0x00000, 0x80000, 0x9ee1a542 )
  550.  
  551.     ROM_REGION( 0x40000, REGION_SOUND2 ) /* uPD7759 data (chip 2) */
  552.     ROM_LOAD( "797a04",    0x000000, 0x40000, 0x9ac8ea4e )
  553. ROM_END
  554.  
  555.  
  556.  
  557. GAMEX( 1987, bladestl, 0,        bladestl, bladestl, 0, ROT90, "Konami", "Blades of Steel (version T)", GAME_IMPERFECT_SOUND )
  558. GAMEX( 1987, bladstle, bladestl, bladestl, bladstle, 0, ROT90, "Konami", "Blades of Steel (version E)", GAME_IMPERFECT_SOUND )
  559.